System simulator, simulation method and simulation program

ABSTRACT

The system simulator comprises master simulators  1   f   , 1   s   , 2   f  and  2   s  for simulating a bus master, a slave simulator L for simulating a bus slave, a function manager F for sequentially actuating the master simulator and the slave simulator by using a function call and a thread manager S for actuating the master simulator by using a thread switching. When the master simulator activated by using the function call from the function manager accesses the slave simulator and an access blocking is caused, the master simulator controls the thread manager such that the master simulator is activated by using the thread switching carried out by the thread manager. Thus, it is possible to carry out the simulation at a high speed without getting into a dead lock state caused by the access blocking and without changing the simulator for simulating a conventional bus master.

BACKGROUND OF THE INVENTION

[0001] 1. Field of the Invention

[0002] The present invention relates to a system simulator, a simulation method and a simulation program. More particularly, the present invention relates to a technique for simulating such a system that a bus master and a bus slave are connected to each other through a bus.

[0003] 2. Description of the Related Art

[0004] Conventionally, as an apparatus to which a microprocessor is applied, such a system that a bus master (hereafter, merely referred to as “Master”) and a bus slave (hereafter, merely referred to as “Slave”) are connected to each other through a bus is known. The software applied to this system is typically developed by using the hardware after the hardware environment to operate the software is prepared, in other words, after the completion of the development of the hardware.

[0005] However, in above-mentioned conventional developing method, a long time is required to develop the system. Therefore, recently, in order to reduce the developing period, such a developing method is employed that the development of the software is carried out on a system simulator. By employing this method, the development of the software can be carried out in parallel with the development of the hardware. As a result, the developing period can be reduced.

[0006]FIG. 1 shows a configuration of a conventional system simulator (hereafter, referred to as “system simulator according to a first conventional technique”) used for the development of the software. This system simulator comprises a first master, a second master, a slave and a manager.

[0007] The first master is a simulator composed of a program for simulating an operation of a device used as a master such as CPU and DMA. The second master is another simulator composed of a program for simulating another device used as the master. The slave is a simulator composed of a program for simulating a peripheral circuit used as a slave such as a timer, a serial input output port, a general input output port and a memory. The manger is the control program for operating the first master, the second master and the slave in synchronization with each other.

[0008] The system simulator according to the first conventional technique having the above-mentioned configuration is used to verify the correctness of the program incorporated in each of the first master, the second master and the slave.

[0009] In the system simulator according to this first conventional technique, the simulation is advanced while the manager performs a function call to the first master, the second master and the slave, sequentially. In detail, the manager firstly performs the function call to the first master. Accordingly, the first master executes a process corresponding to one clock. For example, if the target of the function call is an instruction to be completed in one clock, the execution of the instruction is carried out. After that, the control is returned back to the manger. If the target of the function call is an instruction requiring a plurality of clocks, the control is returned back to the manager after the completion of a process corresponding to the one clock.

[0010] Next, the manager performs the function call to the second master, similarly to the above-mentioned case. Continuously, the manager performs the function call to the slave. After that, the simulation is advanced by that the function call to the first master →the second master→the slave→the first master → . . . is cyclically performed. It should be noted that, if the target of the function call is the instruction requiring the plurality of clocks, the execution of the instruction is completed by executing the plurality of function calls to the target.

[0011] As described above, the first master, the second master and the slave sequentially execute the process corresponding to the one clock for each execution of the function call from the manager. Thus, the first master, the second master and the slave are operated as if they are in synchronization with the clock. That is, it can be considered that the first master, the second master and the slave are operated such that the operational timings are given from the manager. Hence, it is possible to carry out the simulation in which the operational timings are considered.

[0012]FIG. 2 shows a configuration of another conventional system simulator (hereafter, referred to as “system simulator according to a second conventional technique”) using a semaphore as a synchronizing mechanism for synchronizing a plurality of simulators with each other. The system simulator according to the second conventional technique always carries out a multi-thread operation.

[0013] The system simulator according to this second conventional technique comprises a first master, a second master, a slave, a manager and a bus. The first master, the second master, the slave and the manager have the functions similar to those of the above-mentioned conventional system simulator according to the first conventional technique, respectively. The bus is the simulator for simulating the operation of the bus when the first master and the second master access the slave.

[0014] In FIG. 2, symbols “o” in the first master, the second master, the manager and the bus denote the semaphores. A symbol “P” denotes an execution of a post, a symbol “W” denotes an execution of a wait, and a symbol “T” denotes an execution of a try wait, respectively. The try wait is a function of carrying out an inquiry to the bus. The system simulator according to this second conventional technique is controlled so as to activate only one of the first master, the second master and the manager at the same time.

[0015] Basically, the manager performs the post “P” to the semaphore of the first master and the second master (hereafter, they may be merely collectively referred to as “master”), and thereby activates the thread of the master, and the manager itself enters in the wait “W” state. Also, the master performs the post “P” to the semaphore of the manager, and thereby returns the control back to the manager, and the master itself enters in the wait “W” state. The slave is activated when the manager performs the function call to the slave, similarly to the system simulator according to the first conventional technique.

[0016] The actual operations of the system simulator according to this second conventional technique will be described below with reference to FIGS. 3 to 5.

[0017]FIG. 3 is an explanatory diagram showing the transfer operation between the manager and the first master. Dotted lines indicate the flow of the control. The manager firstly performs the post to the semaphore of the first master, and the manager itself enters in the wait state. This post operation activates the thread of the first master being in the wait state, and the try wait is performed to the semaphore of the bus. Then, if this try wait is unsuccessful, the first master performs the post to the semaphore of the manager, and the first master enters in the wait state.

[0018]FIG. 4 is an explanatory diagram showing the transfer operation between the manager and the second master. Dotted lines indicate the flow of the control. As mentioned above, when the control is transferred to the manager by that the first master performs the post to the semaphore of the manager, the manager then performs the post to the semaphore of the second master, and the manager itself enters in the wait state. This post operation activates the thread of the second master being in the wait state, and the try wait is performed to the semaphore of the bus. Then, if this try wait is unsuccessful, the second manager performs the post to the semaphore of the manager, and the second master enters in the wait state.

[0019]FIG. 5 is an explanatory diagram showing the transfer operation between the manager and the slave. Dotted lines indicate the flow of the control. As mentioned above, when the control is transferred to the manager by that the second master performs the post to the semaphore of the manager, the manager then performs the function call to the slave. If the slave becomes at a state responsible to an access request from the first master and the second master, the slave performs the post to the semaphore of the bus. This implies that the next try waits perfumed by the first and second masters are successful. After that, the control is returned from the slave to the manager. After that, the above-mentioned operations are repeated.

[0020] As mentioned above, the first and second masters, while carrying out the thread switching, sequentially execute the process corresponding to the one clock in each thread, and the slave executes the process corresponding to the one clock for each performance of the function call from the manager. Thus, the first master, the second master and the slave are operated as if they are in synchronization with the clock. Hence, it is possible to carry out the simulation in which the operational timings are considered.

[0021] In this system simulator according to the second conventional technique, when the master accesses the slave, even if an access blocking occurs, namely, even if the master fails in the try wait of the bus, there is no case that the master continues to wait for the response. Thus, there is no case that this system simulator gets into a dead lock state.

[0022] As a related art, Japanese Laid Open Patent Application (JP-A-Heisei 11-296408) discloses a software logic simulator for an assembled apparatus. This software logic simulator can attain a simulation for hardware by a plurality of applications, and carry out a linkage operation between them, and thereby simplify the description of the hardware operations, and further improve a debugging efficiency of software. According to this simulator, if the debugging operation is performed in linkage between the hardware simulator and the software, it is possible to solve the problems that the speed of the simulation of the hardware operation is very slow and that the description of the hardware has a defect.

[0023] However, the system simulator according to the first conventional technique has the following problem. That is, the program of the master includes the instruction to access to the slave. When the master executes this instruction, if the slave can respond to it within a time corresponding to the one clock, there is no problem. However, most of the slaves require several clocks for the response. The above mentioned phenomenon that the slave can not immediately respond to the access from the master is referred to as “Access Blocking”. The access blocking includes a read access blocking and a write access blocking.

[0024] If the access blocking occurs, the master enters in the waiting state for waiting the response from the slave, and the control is not returned back to the manager. Consequently, the clock is not supplied to the slave. Thus, the master still continues the waiting state, and the system simulator gets into the dead lock state.

[0025] This problem can be solved by changing the specification of the slave on the system simulator such that the response is returned in one clock. However, in this approach, because the specification of the slave on the system simulator differs from that of the actual slave, it is impossible to carry out the simulation by considering the operation timing. The above-mentioned problem can be also solved by designing the program of the master such that the master being in the waiting state for waiting the response from the slave forcedly returns the control to the manager. However, in this approach, it is necessary to re-design the conventional program of the master. Moreover, when it is re-designed, the structure of the program of the master becomes complex. Thus, the development of the program of the master requires a large number of steps.

[0026] The system simulator according to the second conventional technique does not get into the dead lock state. However, it has the following problem. That is, in this system simulator, the thread switching is always performed under the control of a thread controller. Thus, this thread switching causes an occurrence of a loss time. The amount of the loss time is determined depending on the program installed in the master. According to the measurement by the inventors of the present invention, the simulation time of the system simulator according to the second conventional technique is equal to about 20 to 40 times the simulation time of the system simulator according to the first conventional technique.

SUMMARY OF THE INVENTION

[0027] Therefore, an object of the present invention is to provide a system simulator, a simulation method and a simulation program, which can carry out a simulation at a high speed without getting into a dead lock state and without changing a simulator for simulating a conventional bus master.

[0028] Means for achieving the object will be described below using reference numerals and symbols used in “Embodiments of the invention”. These reference numerals and symbols are added so that relation between the description of “Scope of the Patent to be claimed” and the description of “Embodiments of the invention” is made clear. However, it is never permitted to use the reference numerals and symbols for the interpretation of technical scopes of the inventions described in “Scope of the Patent to be claimed” and the description of “Embodiments of the invention”.

[0029] In order to attain the above-mentioned object, a system simulator according to a first aspect of the present invention comprises a master simulator (1 f, 1 s, 2 f and 2 s), a slave simulator (L), a function manager (F) and a thread manager (S). The master simulator (1 f, 1 s, 2 f and 2 s) simulates a bus master. The slave simulator (L) simulates a bus slave. The function manager (F) sequentially activates the master simulator (1 f, 1 s, 2 f and 2 s) and the slave simulator (L) by using a function call. The thread manager (S) activates the master simulator (1 f, 1 s, 2 f and 2 s) by using a thread switching. In this system simulator, when the master simulator (1 f, 1 s, 2 f and 2 s) activated by using the function call from the function manager (F) accesses to the slave simulator (L) and an access blocking is caused, the master simulator (1 f, 1 s, 2 f and 2 s) controls the thread manager (S) such that the master simulator (1 f, 1 s, 2 f and 2 s) is activated by using the thread switching carried out by the thread manager (S).

[0030] This system simulator can be designed such that the thread manager (S) further activates the slave simulator (L) by using the function call. Also, after the access blocking is canceled, the thread manager (S) controls the function manager (F) such that the master simulator (1 f, 1 s, 2 f and 2 s) is activated by using the function call.

[0031] In order to attain the above-mentioned object, a simulation method according to a second aspect of the present invention comprises steps of (1) providing a master simulator (1 f, 1 s, 2 f and 2 s) for simulating a bus master and a slave simulator (L) for simulating a bus slave, (2) sequentially actuating the master simulator (1 f, 1 s, 2 f and 2 s) and the slave simulator (L) by using a function call and (3) actuating the master simulator (1 f, 1 s, 2 f and 2 s) by using a thread switching, when the master simulator (1 f, 1 s, 2 f and 2 s) activated by using the function call accesses to the slave simulator (L) and causes an access blocking.

[0032] This simulation method can be designed such that the step (3) further activates the slave simulator (L) by using the function call. Also, the simulation method further comprises actuating the master simulator (1 f, 1 s, 2 f and 2 s) by using the function call, after the access blocking is canceled.

[0033] In order to attain the above-mentioned object, a system simulation program according to a third aspect of the present invention comprises a master simulation program (1 f, 1 s, 2 f and 2 s), a slave simulation program (L), a function manager program (F) and a thread manager program (S). The master simulation program (1 f, 1 s, 2 f and 2 s) simulates a bus master. The slave simulation program (L) simulates a bus slave. The function manager program (F) sequentially activates the master simulation program (1 f, 1 s, 2 f and 2 s) and the slave simulation program (L) by using a function call. The thread manager program (S) activates the master simulation program (1 f, 1 s, 2 f and 2 s) by using a thread switching. In this system simulation program, when the master simulation program (1 f, 1 s, 2 f and 2 s) activated by using the function call from the function manager program (F) accesses to the slave simulation program (L) and an access blocking is caused, the master simulation program (1 f, 1 s, 2 f and 2 s) controls the thread manager program (S) such that the master simulation program (1 f, 1 s, 2 f and 2 s) is activated by using the thread switching carried out by the thread manager program (S).

[0034] This system simulation program can be designed such that the thread manager program (S) further activates the slave simulation program (L) by using the function call. Also, after the access blocking is canceled, the thread manager program (S) controls the function manager program (F) such that the master simulation program (1 f, 1 s, 2 f and 2 s) is activated by using the function call.

BRIEF DESCRIPTION OF THE DRAWINGS

[0035]FIG. 1 shows a configuration of a system simulator according to a first conventional technique;

[0036]FIG. 2 shows a configuration of another system simulator according to a second conventional technique;

[0037]FIG. 3 is an explanatory diagram showing the transfer operation between a first master and a manager in the system simulator shown in FIG. 2;

[0038]FIG. 4 is an explanatory diagram showing the transfer operation between a second master and the manager in the system simulator shown in FIG. 2;

[0039]FIG. 5 an explanatory diagram showing the transfer operation between a slave and the manager in the system simulator shown in FIG. 2;

[0040]FIG. 6 is a function block diagram showing a configuration of a system simulator according to an embodiment of the present invention;

[0041]FIG. 7 is an explanatory diagram showing an operation when an access blocking does not occur, in the system simulator according to the embodiment of the present invention;

[0042]FIG. 8 is an explanatory diagram showing an operation (No.1) when an access blocking occurs, in the system simulator according to the embodiment of the present invention;

[0043]FIG. 9 is an explanatory diagram showing an operation (No.2) when the access blocking occurs, in the system simulator according to the embodiment of the present invention;

[0044]FIG. 10 is an explanatory diagram showing an operation (No.3) when the access blocking occurs, in the system simulator according to the embodiment of the present invention;

[0045]FIG. 11 is an explanatory diagram showing an operation (No.4) when the access blocking occurs, in the system simulator according to the embodiment of the present invention;

[0046]FIG. 12 is a flowchart showing a main process in the system simulator according to the embodiment of the present invention;

[0047]FIG. 13 is a flowchart showing in detail a process for generating a thread of a master s in FIG. 12;

[0048]FIG. 14 is a flowchart showing in detail a process for advancing system time of a manager F by one clock in FIG. 12;

[0049]FIG. 15 is a flowchart showing in detail a process for advancing system time of a manager S by one clock in FIG. 12;

[0050]FIG. 16 is a flowchart showing in detail a process of a step S27 in FIG. 14;

[0051]FIG. 17 is a flowchart showing in detail a process of a step S64 in FIG. 16;

[0052]FIG. 18 is a flowchart showing in detail a process of a step S71 in FIG. 17;

[0053]FIG. 19 is a flowchart showing in detail a process of a step S75 in FIG. 17;

[0054]FIG. 20 is a flowchart showing in detail a process of a step S42 in FIG. 15; and

[0055]FIG. 21 is a flowchart showing in detail a process of a step S95 in FIG. 20.

DESCRIPTION OF THE PREFERRED EMBODIMENT

[0056] Embodiment of the present invention will be described below in detail with reference to the attached drawings.

[0057]FIG. 6 is a function block diagram showing the configuration of a system simulator according to an embodiment of the present invention. This simulator is established on an information processing apparatus, such as a personal computer, a work station or a general purpose computer, by installing software. The configuration and the operation of the information processing apparatus are well known. Therefore, their explanations are omitted.

[0058] This system simulator is composed of a first master 1 f for a function (hereinafter, referred to as “function first master 1 f”), a first master is for a thread (hereinafter, referred to as “thread first master 1 s”), a second master 2 f for a function (hereinafter, referred to as “function second master 2 f”), a second master 2 s for a thread (hereinafter, referred to as “thread second master 2 s”), a function manager F, a thread manger S, a slave L and a bus B.

[0059]FIG. 6 also shows the transfer of the control in this system simulator. That is, symbols “o” included in the thread first master 1 s, the thread second master 2 s, the function manager F, the thread manger S and the bus B denote semaphores. Also, a symbol “P” denotes an execution of a post, a symbol “W” denotes an execution of a wait, and a symbol “T” denotes an execution of a try wait, respectively. In FIG. 6, an arrow of an alternate long and short dash line denotes the transfer of the control resulting from the function call, an arrow of a solid line denotes the transfer of the control resulting from the post, an arrow of a broken line denotes the transfer of the control resulting from the wait, and an arrow of an alternate long and two short dashes line denotes the transfer of the control resulting from the try wait, respectively. Moreover, an arrow of a double line denotes an execution of the thread.

[0060] The function first master 1 f is a simulator composed of a program for simulating an operation of a device used as a master such as CPU and DMA. This function first master 1 f performs a read access and a write access to the slave L through the bus B. This function first master 1 f is the same thread as the function manager F, and starts an operation in accordance with the function call for each one clock from the function manager F. After the execution of the simulation corresponding to the one clock, the control is returned back to the function manager F.

[0061] The thread first master 1 s is a simulator composed of a program for simulating the operation of the device used as the master, similarly to the above-mentioned function first master 1 f. This thread first master 1 s performs the read access and the write access to the slave L through the bus B. This thread first master 1 s is a thread different from that of the function manager F. The thread first master 1 s starts the execution when the thread manger S, which is also a thread different from that of the function manager F, performs the post to the semaphore of the thread first master is. After the completion of the execution, the control is transferred to the thread manger S by performing the wait to the semaphore.

[0062] The function first master 1 f and the thread first master is are constituted as one module, and they are the different threads although having the same text. Actually, the function first master 1 f and the thread first master is are only different in an execution start position in the module.

[0063] The function second master 2 f is a simulator composed of a program for simulating an operation of a device used as a master, similarly to the above-mentioned the function first master 1 f. This function second master 2 f performs a read access and the write access to the slave L through the bus B. This function second master 2 f is the same thread as the function manager F, and starts an operation in accordance with the function call for each one clock from the function manager F. After the execution of the simulation corresponding to the one clock, the control is returned back to the function manager F.

[0064] The thread second master 2 s is a simulator composed of a program for simulating the operation of the device used as the master, similarly to the above-mentioned function second master 2 f. This thread second master 2 s performs the read access and the write access to the slave L through the bus B. This thread second master 2 s is a thread different from the function manager F. The thread second master 2 s stats the execution when the thread manger S, which is also a thread different from that of the function manager F, performs the post to the semaphore of the thread second master 2 s. After the completion of the execution, the control is transferred to the thread manger S by performing the wait to the semaphore.

[0065] The function second master 2 f and the thread second master 2 s are constituted as one module, and they are the different threads although having the same text. Actually, the function second master 2 f and the thread second master 2 s are only different in an execution start position in the module The slave L is a simulator composed of a program for simulating a peripheral circuit used as a slave such as a timer, a serial port or a general input output port. This slave L carries out a predetermined operation in response to the read access and the write access performed through the bus B from the function first master 1 f, the thread first master 1 s, the function second master 2 f and the thread second master 2 s. This slave L starts an execution in accordance with the function call from the function manager F and the thread manger S.

[0066] The bus B is a simulator composed of a program for simulating a bus through which the slave L and each of the function first master 1 f, the thread first master 1 s, the function second master 2 f and the thread second master 2 s are connected. This bus B returns the information indicating whether or not the slave L can immediately respond, namely, whether or not the access blocking occurs, in response to an inquiry by using the try wait from the function first master 1 f, the thread first master 1 s, the function second master 2 f and the thread second master 2 s.

[0067] The function manager F is a control program for performing the function call to the function first master 1 f, the thread first master 1 s and the slave L in turn, and allowing them to operate in synchronization with each other.

[0068] The thread manger S is a control program for carrying out the thread switching to allow the thread first master 1 s and the thread second master 2 s to operate, and carrying out the function call to the slave for allowing it to operate.

[0069] An operation of the system simulator according to the embodiment of the present invention having the above-mentioned configuration will be described below. This system simulator is controlled so as to activate only one of the function first master 1 f, the thread first master 1 s, the function second master 2 f, the thread second master 2 s, the function manager F and the thread manger S at the same time.

[0070] At first, the operation when the access blocking does not occur is described with reference to FIG. 7. In this case, the system simulator is operated similarly to the simulator according to the first conventional technique. That is, the simulation is advanced while the function manager F performs the function call to the function first master 1 f, the function second master 2 f and the slave L in turn.

[0071] In detail, the function manager F firstly performs the function call to the function first master 1 f. Accordingly, the function first master 1 f executes a process corresponding to one clock. For example, if the target of the function call is an instruction to be completed in one clock, the control is returned back to the function manager F after the completion of the execution of the instruction. In this process, it is assumed that the access blocking does not occur. Thus, even in a case of a process for accessing the bus B, the process is completed in the one clock. It should be noted that, if the target of the function call is an instruction requiring a plurality of clocks, the control is returned back to the function manager F after the completion of a process corresponding to the one clock.

[0072] Next, similarly to the above-mentioned conventional case, the function manager F performs the function call to the function second master 2 f, and then performs the function call to the slave L. After that, the simulation is advanced by the cyclic performance of the function call to the function first master 1 f→the function second master 2 f→the slave L→the function first master 1 fΔ . . . . It should be noted that, if the target of the function call is the instruction requiring the plurality of clocks, the instruction is completed by executing the plurality of function calls to the target.

[0073] As mentioned above, unless the access blocking occurs, the function first master 1 f, the function second master 2 f and the slave L sequentially execute the process corresponding to the one clock for each execution of the function call from the function manger F. Thus, they are operated as if they are in synchronization with the clock. Hence, it is possible to carry out the simulation in which the operational timings are considered.

[0074] Nest, the operations in the case of the occurrence of the access blocking will be described below with reference to FIGS. 8 to 11. In this case, the system simulator according to this embodiment is operated similarly to the simulator according to the second conventional technique.

[0075]FIG. 8 is an explanatory diagram showing an operation when the access blocking occurs in the process of the function first master 1 f, to which the function manager F performs the function call, and the control is transferred to the thread manger S. Dotted lines indicate the flow of the control.

[0076] The function manager F firstly performs the function call to the function first master 1 f. Accordingly, the function first master 1 f executes the process corresponding to the one clock. In this process, the function first master 1 f performs the try wait to the semaphore of the bus B. If the try wait is successful, namely, if the access blocking does not occur, the function first master 1 f completes the process corresponding to the one clock, as mentioned above, and the control is returned back to the function manager F.

[0077] On the other hand, if the try wait is unsuccessful, namely, if the access blocking occurs, as shown by an arrow of dotted lines, the function first master 1 f performs the post to the semaphore of the thread manger S, and performs the wait to the semaphore of the function manager F. Thus, the control is transferred from the function manager F to the thread manger S. That is, the thread manger S is activated, and the function manager F enters in a sleep state. After that, the simulation based on the thread switching is started under the control of the thread manger S.

[0078]FIG. 9 is an explanatory diagram showing an operation when the access blocking occurs in the process of the thread second master 2 s, in which the thread is activated by the thread manger S, and the control is transferred to the thread manger S. The dotted line indicates the flow of the control.

[0079] Following the operation shown in FIG. 8, the thread manger S performs the post to the semaphore of the thread second master 2 s, and thereby activates the thread of the thread second master 2 s. Then, the thread manger S itself enters in the wait state. The thread of the thread second master 2 s performs the try wait to the semaphore of the bus B.

[0080] As shown by an arrow of a dotted line in FIG. 9, if the try wait is successful, namely, if the access blocking does not occur, after the completion of the process corresponding to the one clock, the thread second master 2 s performs the post to the semaphore of the thread manger S, and enters in the wait state. On the other hand, if the try wait is unsuccessful, namely, if the access blocking occurs, the thread second master 2 s immediately performs the post to the semaphore of the thread manger S, and enters in the wait state.

[0081]FIG. 10 is an explanatory diagram showing an operation when the slave L, to which the thread manger S performs the function call, completes the process, and the control is then transferred to the thread manger S. The dotted line indicates the flow of the control.

[0082] Following the operation shown in FIG. 9, the thread manger S performs the function call to the slave L. Accordingly, the slave L executes the process corresponding to the one clock. In the slave L, when data is prepared in response to a read request from the function first master 1 f, the thread first master 1 s, the function second master 2 f and the thread second master 2 s, the slave L performs the post to the semaphore of the bus B. Accordingly, the access blocking state in the bus B is released. After that, the control is returned back to the thread manger S.

[0083]FIG. 11 is an explanatory diagram showing an operation when the access blocking does not occur in the process of the thread first master 1 s, to which the thread manger S performs the function call, and the control is transferred to the function manager F. The dotted line indicates the flow of the control.

[0084] Following the operations shown in FIG. 10, the thread manger S performs the post to the semaphore of the function manager F. Accordingly, the function first master 1 f being in the wait state because of the failure of the try wait is activated and, the function first master 1 f again performs the try wait to the semaphore of the bus B. If the try wait is successful, namely, if the access blocking does not occur, the function first master 1 f completes the process corresponding to the one clock, and the control is returned back to the function manager F.

[0085] On the other hand, if the try wait is unsuccessful, namely, if the access blocking is not canceled, as described with reference to FIG. 8, the function first master 1 f performs the post to the semaphore of the thread manger S. After that, the operations similar to those of the above-mentioned case are repeated. When the access blocking is canceled, all the masters are executed in accordance with the function call.

[0086] In the system simulator according to the embodiment of the present invention having the above-mentioned configuration, the already-developed instruction set simulator for simulating a single CPU can be used as the simulator of the master as its original state. Thus, it is not necessary to redesign the simulator.

[0087] Also, if the access blocking occurs, it is switched from the simulation based on the function call to the simulation based on the thread switching. Thus, differently from the conventional technique, the occurrence of the access blocking never causes the system simulator to get into the dead lock.

[0088] Moreover, unless the access blocking occurs, the simulation is executed in accordance with the function call, and the operation based on the thread switching is not performed. As a result, it is possible to reduce the loss time caused by the thread switching to a minimum, and thereby possible to attain the simulation at a high speed.

[0089] In order to more understand the present invention, the processes for attaining the above-mentioned operations will be further described below with reference to the flowcharts, mainly in the switching operation between the function manager F and the thread manger S.

[0090]FIG. 12 is a flowchart showing the main process in the system simulator according to this embodiment.

[0091] In this system simulator, in the function manager F (hereafter, merely referred to as “Manger F”) and the thread manger S (hereafter, merely referred to as “Manager S”), the function first master 1 f, the thread first master 1 s, the function second master 2 f and the thread second master 2 s (hereafter, they may be collectively merely referred to as “Master”) are managed by a table. It should be noted that, hereafter, the function first master 1 f and the function second master 2 f may be sometime merely referred to as “Master f” and the thread first master 1 s and the thread second master 2 s may be sometime merely referred to as “Master s”.

[0092] A current master table index “current_master_table_index” is a table index of a master to advance a clock, which is shared by a manager F and a manager S.

[0093] When the simulation is started in the system simulator, at first, the current master table index “current_master_table_index” and a current slave table index “current_slave_table_index” is initially set to zero (Step S10, S11). Then, the thread of the manager S to be used in the simulation is generated (Step S12).

[0094] Next, after the execution of the thread generating process of the master s (Step S13) as described later in detail, with regard to the manager F, a process for advancing system time of the manager F by one clock is repeated until an end of the simulation is indicated (Steps S14, S15). On the other hand, with regard to the manager S, the wait is performed on the semaphore of the manager S (Step S16). Then, a process for advancing system time of the manager S by one clock is repeated until the end of the simulation is indicated (Steps S17, S18).

[0095] Thus, the simulation is started when the function manager F executes the function call (Steps S14 and S15) at the initial state. After that, the processes at the steps S14 and S17 are suitably executed depending on the presence or absence of the access blocking.

[0096] The thread generating process of the master s carried out at the step S13 will be described below in detail with reference to the flowchart shown in FIG. 13.

[0097] A current master index “current_master_index” is an index of a master s to be advanced the clock by the manager S.

[0098] In the thread generating process of the master s, at first, a current master index “current_master_index” is initially set to zero (Step S20). Next, it is checked whether or not the current master index is smaller than a master table size “master_table_size” (Step S21). When it is judged to be smaller, the thread of the master s corresponding to the current master index “current_master_index” is generated (Step S22).

[0099] Next, while the process for advancing system time of the master s by one clock (Step S24) as described later in detail is carried out, a value of the current master index “current_master_index” is incremented by one (Step S23). Then, in order to generate a thread of a next master s, the sequence returns back to the step S21, and the above-mentioned operations are repeated. At the step S21, if the current master index is judged to be equal to or greater than the master table size, the thread generating process of the master s is ended.

[0100] The process for advancing the system time of the manager F by one clock performed at the step S14 will be described below in detail with reference to the flowchart shown in FIG. 14.

[0101] In this process, it is firstly checked whether or not the current master table index “current_master_table_index” is smaller than the master table size “master_table_size” (Step S25). When it is judged to be smaller, a process “cur_index=current_master_table_index++” is executed for substituting a value of the current master table index “current_master_table_index” into a current index “cur_index” and then incrementing the value of the current master table index “current_master_table_index” by one (Step S26).

[0102] Next, a process is carried out for advancing a time by one clock when the table index of the master performs the function call to the master of the current index “cur_index” (Step S27). This process will be described later in detail. Then, it is checked whether or not an association array storing therein the information of the master, in which the access blocking occurs, is empty (Step S28). When the association array is judged to be empty, it is recognized that the access blocking does not occur. Then, the sequence returns back to the step S25, and the above-mentioned operations are repeated for a next master.

[0103] On the other hand, if the association array is judged to be not empty, it is recognized that the access blocking occurs, and the post is performed to the semaphore of the manager S (Step S29), and the wait is performed to the semaphore of the manager F (Step S30). Accordingly, the control is transferred from the manager F to the manager S. Then, the simulation based on the thread switching is started under the control of the manager S. After that, the sequence returns back to the step S25, and the above-mentioned operations are repeated for a next master.

[0104] At the step S25, if the current master table index “current_master_table_index” is judged to be equal to or greater than the master table size “master_table_size2, the current master table index “current_master_table_index” is reset to zero (Step S31).

[0105] Next, it is checked whether or not the current slave table index “current_slave_table_index” is smaller than a slave table size “slave_table_size” (Step S32). When it is judged to be smaller, a process “cur_index=current_slave_table_index++” is executed for substituting a value of the current slave table index “current_slave_table_index” into the current index “cur_index” and then incrementing the value of the current slave table index “current_slave_table_index” by one (Step S33).

[0106] Next, a process is carried out for advancing a time by one clock when the table index of the slave performs the function call to the slave of the current index “cur_index” (Step S34). After that, the sequence returns back to the step S25, and the above-mentioned operations are repeated for a next slave.

[0107] At the step S32, when the current slave table index “current_slave_table_index” is judged to be equal to or greater than the slave table size “slave_table_size”, the current slave table index “current_slave_table_index” is reset to zero (Step S35). After performing this step, the process for advancing the system time of the manager F by the one clock is ended, and the sequence returns back to the main process.

[0108] The process for advancing the system time of the manager S by one clock done at the step S17 will be described below in detail with reference to the flowchart shown in FIG. 15.

[0109] In this process, it is firstly checked whether or not the current master table index “current_master_table_index” is smaller than the master table size “master_table_size” (Step S40). When it is judged to be smaller, a process “cur_index=current_master_table_index++” is executed for substituting the value of the current master table index “current_master_table_index” into the current index “cur_index” and then incrementing the value of the current master table index “current_master_table_index” by one (Step S41).

[0110] Next, a process is carried out in which the table index of the master advances the time of the master s of the current index “cur_index” by one clock (Step S42). This process will be described later in detail. Here, if it is set that the post is performed to the semaphore of the manager F in accordance with a report indicative of an occurrence of the access blocking, the post is performed to the semaphore of the manager F. Otherwise, the post is performed to the corresponding master s.

[0111] Next, the wait is performed to the semaphore of the manager S (Step S43). Then, it is checked whether or not the association array is empty (Step S44). When the association array is judged to be empty, it is recognized that the access blocking does not occur. Then, the sequence returns back to the step S40, and the above-mentioned operations are repeated for a next master.

[0112] On the other hand, if the association array is judged to be not empty, it is recognized that the access blocking occurs, and the post is performed to the semaphore of the manager F (Step S45), and the wait is performed to the semaphore of the manager S (Step S46). Accordingly, the control is transferred from the manager S to the manager F. Then, the simulation based on the function call is carried out under the control of the manager F. After that, the sequence returns back to the step S40, and the above-mentioned operations are repeated for a next master.

[0113] At the step S40, when the current master table index “current_master_table_index” is judged to be equal to or greater than the master table size “master_table_size”, the current master table index “current_master_table_index” is reset to zero (Step S47).

[0114] Next, it is checked whether or not the current slave table index “current_slave_table_index” is smaller than the slave table size “slave_table_size” (Step S48). When it is judged to be smaller, the process “cur_index=current_slave_table_index++” is executed for substituting the value of the current slave table index “current_slave_table_index” into the current index “cur_index” and then incrementing the value of the current slave table index “current_slave_table_index” by one (Step S49).

[0115] Next, a process is carried out for advancing a time by one clock when the table index of the slave performs the function call to the slave of the current index “cur_index” (Step S50). After that, the sequence returns back to the step S48, and the above-mentioned operations are repeated for a next slave.

[0116] On the other hand, at the step S48, when the current slave table index “current_slave_table_index” is judged to be equal to or greater than the slave table size “slave_table_size”, the current slave table index “current_slave_table_index” is reset to zero (Step S51). After performing this step, the process for advancing the system time of the manager S by the one clock is ended, and the sequence returns back to the main process.

[0117] The process for advancing the time of the master by one clock performed at the step S27 shown in FIG. 14 will be described below in detail with reference to the flowchart shown in FIG. 16. It should be noted that a case in which CPU is used as the master is exemplified in the following explanation.

[0118] In this process, an instruction is firstly fetched (Step S60). Next, the fetched instruction is decoded (Step S61). Any one of an NOP instruction (Step S62), an ADD instruction (Step S63), a LOAD instruction (Step S64), . . . is executed on the basis of the decoded result. When the corresponding instruction does not exist as the decoded result, an error process is carried out (Step S65).

[0119] An operation of the LOAD instruction executed in accordance with the function call from the manager F will be described below with reference to the flowchart shown in FIG. 17.

[0120] When this LOAD instruction is executed, it is firstly checked whether or not load data can be obtained through the bus from the slave (Step S70). In this step S70, when it is so judged that the load data can not be obtained, a process for reporting an access blocking occurrence common to the master f and the master s is carried out (Step S71). This process for reporting the access blocking occurrence is shown in detail in the flowchart of FIG. 18.

[0121] In this process for reporting the access blocking occurrence, it is firstly checked whether or not an association array storing therein the information of the master being blocking is empty (Step S80). When it is judged to be empty, if the manager S advances the time of the master, it is set such that the post is performed to the semaphore of the manager F (Step S81). On the other hand, if it is judged to be not empty, the process at the step S81 is skipped. Next, the master is recorded in the association array for storing the information of the master being blocking (Step S82). After that, the sequence returns back to the step S72 of FIG. 17.

[0122] At the step S72, the post is performed to the semaphore of the manager S. Next, the wait is performed to the semaphore of the manager F (Step S73). After that, the sequence returns back to the step S70, and the above-mentioned operations are repeated. Accordingly, it is checked whether or not the load data is obtained from the slave for each one clock.

[0123] When it is judged at the step S70 that the load data can be obtained through the bus from the slave, it is then checked whether or not the process for reporting the access blocking occurrence common to the master f and the master s is being called, namely, whether or not the process at the step S71 is being executed (Step S74). When it is judged that the process for reporting the access blocking occurrence common to the master f and the master s is being called, a process for reporting the end of the access blocking common to the master f and the master s is executed (Step S75). This process for reporting the end of the access blocking is shown in detail in the flowchart of FIG. 19.

[0124] This process for reporting the end of the access blocking deletes the master from the association array for storing the information of the master being blocking (Step S85). Then, if the manager S advances the time of the master, it is set that the post is performed to the semaphore of the master s (Step S86). After that, the sequence returns back to the step S76 of FIG. 17.

[0125] At the step S76, the load data obtained through the bus from the slave is written to a resister (not shown) instructed by the LOAD instruction. Accordingly, the execution of the LOAD instruction is completed.

[0126] The process for advancing the time of the master by one clock performed at the step S42 will be described below in detail with reference to the flowchart shown in FIG. 20. It should be noted that a case in which CPU is used as the master is exemplified in the following explanation.

[0127] In this process, the wait is firstly performed to the semaphore of the master s (Step S90). Next, the instruction is fetched (Step S91). Then, the fetched instruction is decoded (Step S92). Any one of the NOP instruction (Step S93), the ADD instruction (Step S94), the LOAD instruction (Step S95), . . . is executed on the basis of the decoded result. When the corresponding instruction does not exist as the decoded result, the error process is performed (Step S96). Then, the post is performed to the semaphore of the manager S (Step S97).

[0128] An operation of the LOAD instruction activated by the master s will be described below with reference to the flowchart shown in FIG. 21.

[0129] When this LOAD instruction is executed, it is firstly checked whether or not the load data can be obtained through the bus from the slave (Step S100). In this step S100, when it is judged that the load data can not be obtained, a process for reporting an access blocking occurrence common to the master f and the master s is done (Step S101). This process for reporting the access blocking occurrence was already described in detail with reference to the flowchart of FIG. 18.

[0130] Next, the post is performed to the semaphore of the manager S (Step S102). Then, the wait is performed to the semaphore of the master s (Step S103). After that, the sequence returns back to the step S100, and the above-mentioned operations are repeated. Accordingly, it is checked whether or not the load data is obtained from the slave for each one clock.

[0131] When it is judged at the step S100 that the load data can be obtained through the bus from the slave, it is then checked whether or not the process for reporting the access blocking occurrence common to the master f and the master s is being called, namely, whether or not the process at the step S101 is being executed (Step S104). When it is judged that the process for reporting the access blocking occurrence common to the master f and the master s is being called, a process for reporting the end of the access blocking common to the master f and the master s is executed (Step S105). This process for reporting the end of the access blocking was already described in detail in the flowchart of FIG. 19.

[0132] Next, the load data obtained through the bus from the slave is written to the resister (not shown) instructed by the LOAD instruction (Step S106). Accordingly, the execution of the LOAD instruction is completed.

[0133] The operations described with reference to FIGS. 7 to 11 are attained by the above-mentioned processes.

[0134] It should be noted that, in the above-mentioned embodiment, the case in the simulation of the apparatus including the two masters and the one slave is described as the example. However, in the present invention, the number of the masters and the number of the slaves are not limited to them. The numbers may be arbitrary.

[0135] As detailed above, according to the present invention, it is possible to provide the system simulator, the simulation method and the simulation program, which can carry out the simulation at the high speed without getting into the dead lock state caused by the access blocking and without changing the simulator for simulating the conventional bus master. 

What is claimed is:
 1. A system simulator comprising: a master simulator which simulates a bus master; a slave simulator which simulates a bus slave; a function manager which sequentially activates said master simulator and said slave simulator by using a function call; and a thread manager which activates said master simulator by using a thread switching, wherein when said master simulator activated by using said function call from said function manager accesses to said slave simulator and an access blocking is caused, said master simulator controls said thread manager such that said master simulator is activated by using said thread switching carried out by said thread manager.
 2. The system simulator according to claim 1, wherein said thread manager further activates said slave simulator by using said function call.
 3. The system simulator according to claim 2, wherein after said access blocking is canceled, said thread manager controls said function manager such that said master simulator is activated by using said function call.
 4. The system simulator according to claim 1, wherein after said access blocking is canceled, said thread manager controls said function manager such that said master simulator is activated by using said function call.
 5. A simulation method comprising: (1) providing a master simulator for simulating a bus master and a slave simulator for simulating a bus slave; (2) sequentially actuating said master simulator and said slave simulator by using a function call; and (3) actuating said master simulator by using a thread switching, when said master simulator activated by using said function call accesses to said slave simulator and causes an access blocking.
 6. The simulation method according to claim 5, wherein said step (3) further activates said slave simulator by using said function call.
 7. The simulation method according to claim 6, further comprising: actuating said master simulator by using said function call, after said access blocking is canceled.
 8. The simulation method according to claim 5, further comprising: actuating said master simulator by using said function call, after said access blocking is canceled.
 9. A simulation program operated on a computer, comprising: a master simulation program which simulates a bus master; a slave simulation program which simulates a bus slave; a function manager program which sequentially activates said master simulation program and said slave simulation program by using a function call; and a thread manager program which activates said master simulation program by using a thread switching, wherein when said master simulation program activated by using said function call from said function manager program accesses to said slave simulation program and an access blocking is caused, said master simulation program controls said thread manager program such that said master simulation program is activated by using said thread switching carried out by said thread manager program.
 10. The simulation program according to claim 9, wherein said thread manager program further activates said slave simulation program by using said function call.
 11. The simulation program according to claim 10, wherein after said access blocking is canceled, said thread manager program controls said function manager program such that said master simulation program is activated by using said function call.
 12. The simulation program according to claim 9, wherein after said access blocking is canceled, said thread manager program controls said function manager program such that said master simulation program is activated by using said function call. 